//
//  ZYPopularViewCell.m
//  Project_B
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 ZY. All rights reserved.
//

#import "ZYPopularViewCell.h"

@interface ZYPopularViewCell ()

@property(nonatomic,strong)UIImageView *headerImgView;/**< 图片*/
@property(nonatomic,strong)UILabel *titleLb;/**< 标题*/
@property(nonatomic,strong)UILabel *contentLb;/**< 图片内容*/
@property(nonatomic,strong)UILabel *replyLb;/**< 跟帖数*/
@end

@implementation ZYPopularViewCell



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}



#pragma mark -
-(void)createSubView{
    
    
    //图片
    self.headerImgView = [[UIImageView alloc]init];
//    self.headerImgView.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.headerImgView];
    self.headerImgView.layer.masksToBounds = YES;
    self.headerImgView.layer.cornerRadius = 3;
    
    
    [_headerImgView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.and.top.mas_equalTo(SPACE);
        make.width.mas_equalTo(HEADERIMG_WIDTH);
        make.height.mas_equalTo(HEADERIMG_HEIGHT);
        
    }];
    
    
    
    
    //标题
    self.titleLb= [[UILabel alloc]init];
//    self.titleLb.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:self.titleLb];
    self.titleLb.font = [UIFont boldSystemFontOfSize:15 * ADAPT_FONT];
    self.titleLb.textColor = [UIColor colorWithHue:0.67 saturation:0.01 brightness:0.33 alpha:1];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.headerImgView.mas_right).offset(SPACE);
        make.top.equalTo(self.headerImgView.mas_top);
        make.right.mas_equalTo(-SPACE);
        make.height.mas_equalTo(SCREEN_WIDTH/20);
        
    }];
    
    
    
    //内容
    self.contentLb = [[UILabel alloc]init];
//    self.contentLb.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:self.contentLb];
    self.contentLb.numberOfLines = 2;
    self.contentLb.font = [UIFont systemFontOfSize:14*ADAPT_FONT];
    self.contentLb.textColor = [UIColor colorWithHue:0.58 saturation:0.01 brightness:0.61 alpha:1];
    
    [_contentLb mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.titleLb.mas_left);
        make.top.equalTo(self.titleLb.mas_bottom);
        make.width.equalTo(self.titleLb);
        make.height.mas_equalTo(SPACE*3);
    }];
    
    
    //跟帖数
    _replyLb = [[UILabel alloc]init];
//    _replyLb.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:_replyLb];
    _replyLb.textAlignment = NSTextAlignmentRight;
    _replyLb.font = [UIFont systemFontOfSize:13*ADAPT_FONT];
    _replyLb.textColor = [UIColor colorWithHue:0.58 saturation:0.01 brightness:0.69 alpha:1];
    
    [_replyLb mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.right.mas_equalTo(-SPACE);
        make.bottom.equalTo(self.headerImgView.mas_bottom);
        make.width.mas_equalTo(HEADERIMG_HEIGHT*1.5);
        make.height.mas_equalTo(SPACE);
        
    }];
}



#pragma mark - set Model
-(void)setModel:(NewestModel *)model{
    _model = model;
    
    self.titleLb.text = _model.title;
    self.contentLb.text = _model.digest;
    [self.headerImgView sd_setImageWithURL:_model.imgsrc placeholderImage:PLACEHOLDER_IMAGE];
    
    
    
    if ([model.skipType isEqualToString:@"special"]) {
        self.replyLb.text = @"专题";
        self.replyLb.textColor = [UIColor redColor];
    }else if ([model.skipType isEqualToString:@"viedio"]){
        self.replyLb.text = [NSString stringWithFormat:@"%@跟帖[视频]",model.replyCount];
        _replyLb.textColor = [UIColor colorWithHue:0.58 saturation:0.01 brightness:0.69 alpha:1];
    }else if ([model.TAG isEqualToString:@"视频"]){
        self.replyLb.text = [NSString stringWithFormat:@"%@跟帖[视频]",model.replyCount];
        _replyLb.textColor = [UIColor colorWithHue:0.58 saturation:0.01 brightness:0.69 alpha:1];
        
    }else{
         self.replyLb.text = [NSString stringWithFormat:@"%@跟帖",model.replyCount];
        _replyLb.textColor = [UIColor colorWithHue:0.58 saturation:0.01 brightness:0.69 alpha:1];
    }
}






#pragma mark -
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
